import { CellRenderer } from "../../../../../fl/controls/listClasses/CellRenderer";
import { ResouceConst } from "../../../../component/gconst/ResouceConst";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ObjCreate } from "../../common/ObjCreate";
import { PlayerScoreData } from "../cellData/PlayerScoreData";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Cache } from "../../../cache/Cache";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
//class PlayerScoreCellRenderer
    
    export  class PlayerScoreCellRenderer extends CellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            this.initStyle();
            this.createChildren();
            this.addListeners();
            return;
        }

        /* internal  */initStyle(): void
        {
            this.setStyle("downSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("overSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("upSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedDownSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedOverSkin", new Object /* flash.display.Bitmap */());
            this.setStyle("selectedUpSkin", new Object /* flash.display.Bitmap */());
            return;
        }

        /* internal  */createChildren(): void
        {
            this._line = ResouceConst.getScaleBitmap("SplitLine");
            this._line.width = 460;
            this._line.height = 2;
            this.addChild(this._line);
            var loc1=new GTextFormat(FontUtil.songtiName, 12, 11661311);
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._tfRank = ObjCreate.createTextField("", 0, 8, 60, 20, this, loc1);
            this._tfName = ObjCreate.createTextField("", 60, 8, 120, 20, this, loc1);
            this._tfGuildName = ObjCreate.createTextField("", 180, 8, 100, 20, this, loc1);
            this._tfKill = ObjCreate.createTextField("", 280, 8, 50, 20, this, loc1);
            this._tfAssist = ObjCreate.createTextField("", 330, 8, 50, 20, this, loc1);
            this._tfScore = ObjCreate.createTextField("", 380, 8, 80, 20, this, loc1);
            return;
        }

        /* internal  */addListeners(): void
        {
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            if (typeof arg1 === "playerscoredata") 
            {
                this._scoreData = arg1 as PlayerScoreData;
                this.updateView();
            }
            return;
        }

        /* internal  */updateView(): void
        {
            var loc1=GlobalStyle.textFormat5;
            loc1.align = flash.text.TextFormatAlign.CENTER;
            this._tfRank.text = this._scoreData.rank.toString();
            this._tfName.text = this._scoreData.guildWarPlayerScore.playerName;
            this._tfGuildName.text = this._scoreData.guildWarPlayerScore.guildName;
            this._tfKill.text = this._scoreData.guildWarPlayerScore.killPlayerNum.toString();
            this._tfAssist.text = this._scoreData.guildWarPlayerScore.assistNum.toString();
            this._tfScore.text = this._scoreData.guildWarPlayerScore.merits.toString();
            if (this._scoreData.guildWarPlayerScore.playerName != Cache.instance.role.entityInfo.name) 
            {
                if (this._star && this._star.parent) 
                {
                    this._star.parent.removeChild(this._star);
                }
            }
            else 
            {
                this._tfRank.setTextFormat(loc1);
                this._tfName.setTextFormat(loc1);
                this._tfGuildName.setTextFormat(loc1);
                this._tfKill.setTextFormat(loc1);
                this._tfAssist.setTextFormat(loc1);
                this._tfScore.setTextFormat(loc1);
                if (!this._star) 
                {
                    this._star = GlobalClass.getBitmap(ImagesConst.ChatGuildMember_star);
                    this._star.x = 0;
                    this._star.y = 6;
                }
                this.addChild(this._star);
            }
            return;
        }

        public /* override */ set label(arg1: string)
        {
            return;
        }

        /* internal */ /* var */_line: ScaleBitmap;

        /* internal */ /* var */_star: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_tfRank: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfName: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfGuildName: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfKill: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfAssist: Object /* flash.text.TextField */;

        /* internal */ /* var */_tfScore: Object /* flash.text.TextField */;

        /* internal */ /* var */_scoreData: PlayerScoreData;
    }
